﻿using System;
using System.Collections.Generic;
using System.Text;

namespace suirui.ZhuMu.Log
{
    public class DefaultLogFactory : ILogFactory
    {
        private Dictionary<string, ILog> _dic = new Dictionary<string, ILog>();

        const string _Default_Loger = "Default";
        const string _Performance_Loger = "Performance";
        const string _Exception_Loger = "Exception";
        const string _Database_Loger = "Database";
        const string _Redis_Loger = "Redis";
        const string _Zhumu_Loger = "Zhumu";
        const string _Message_Loger = "Message";
        const string _Mail_Loger = "Mail";
        const string _Video_Loger = "Video";

        public static readonly DefaultLogFactory Instance = new DefaultLogFactory();
        private DefaultLogFactory() { }

        public ILog GetLog(string logerName)
        {
            lock (_dic)
            {
                if (!_dic.ContainsKey(logerName))
                {
                    _dic[logerName] = new Log4netLoger(logerName);
                }
            }
            return _dic[logerName];
        }

        /// <summary>
        /// 默认日志
        /// </summary>
        public ILog Default_Loger
        {
            get
            {
                return GetLog(_Default_Loger);
            }
        }

        /// <summary>
        /// 邮件日志
        /// </summary>
        public ILog Mail_Loger
        {
            get
            {
                return GetLog(_Mail_Loger);
            }
        }

        /// <summary>
        /// 性能监控
        /// </summary>
        public ILog Performance_Loger
        {
            get
            {
                return GetLog(_Performance_Loger);
            }
        }

        /// <summary>
        /// 消息服务
        /// </summary>
        public ILog Message_Loger
        {
            get
            {
                return GetLog(_Message_Loger);
            }
        }

        /// <summary>
        /// 全局异常
        /// </summary>
        public ILog Exception_Loger
        {
            get
            {
                return GetLog(_Exception_Loger);
            }
        }


        /// <summary>
        /// 数据库日志
        /// </summary>
        public ILog Database_Loger
        {
            get
            {
                return GetLog(_Database_Loger);
            }
        }

        /// <summary>
        /// Redis日志
        /// </summary>
        public ILog Redis_Loger
        {
            get
            {
                return GetLog(_Redis_Loger);
            }
        }

        /// <summary>
        /// Zhumu日志
        /// </summary>
        public ILog Zhumu_Loger
        {
            get
            {
                return GetLog(_Zhumu_Loger);
            }
        }

        /// <summary>
        /// Video转换日志
        /// </summary>
        public ILog Video_Loger
        {
            get
            {
                return GetLog(_Video_Loger);
            }
        }
    }
}
